﻿using Abp.BackgroundJobs;
using Abp.Dependency;
using Abp.Domain.Uow;
using Abp.Threading;
using DHJ.Cost.CostAccounting.Cache;

namespace DHJ.Cost.CostAccounting.Job
{
    public class BatchCostJob : BackgroundJob<int>, ITransientDependency
    {
        private readonly IBatchCostCache _batchCostCache;

        public BatchCostJob(IBatchCostCache batchCostCache)
        {
            _batchCostCache = batchCostCache;
        }

        [UnitOfWork]
        public override void Execute(int args)
        {
            AsyncHelper.RunSync(() => _batchCostCache.InitDetailCache());
            AsyncHelper.RunSync(() => _batchCostCache.InitCache());
        }
    }
}
